const router = require('koa-router')();
const config = require('../config/config.local');

const requestReport = require('./reports/requestReport');
const getReport = require('./reports/getReport');

router.use('', requestReport.routes(), requestReport.allowedMethods());
router.use('', getReport.routes(), getReport.allowedMethods());

router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2! from pt-core-reports'
  })
});

router.get('/ver', async (ctx, next) => {
  const deploymentVersion = config.ver;
  ctx.body = `welcome, deployment version: ${deploymentVersion}`;
});

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
});

module.exports = router;
